import os.path
import re

regex_pin_format = re.compile(r"[^#]*\$(\w+)=(.*)=(.*)", re.IGNORECASE)  # 用于解析引脚地址

def load_PLC_ui(path: str):
    list_data = []  # [(PL_SYM, description, units), ... ]
    with open(path, "r") as fp:
        for str_line in fp.readlines():
            re_match = regex_pin_format.match(str_line)
            if re_match:
                # PL_SYM, description, units = re_match.groups()
                list_data.append(re_match.groups())
    return list_data

if __name__ == "__main__":
    list_ui_data = load_PLC_ui("./test/PLC.ui")
    print(list_ui_data)

